package org.mrzc.resource;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.io.Resource;

public class GetResource implements ApplicationContextAware
{

    private ApplicationContext mApplication;

    Logger mLog = LoggerFactory.getLogger(GetResource.class);

    @Override
    public void setApplicationContext(ApplicationContext cApplicationContext) throws BeansException
    {
        mApplication = cApplicationContext;
    }

    public Resource getResouce(String cPath) throws IOException
    {
        Resource tResource = mApplication.getResource(cPath);
        mLog.debug("fileName = {}", tResource.getFilename());
        mLog.debug("fileLength = {}", tResource.contentLength());
        return tResource;
    }

}
